/*!
\file VisualizationSettings.cpp
\brief Implementation of VisualizationSettings class.
\ingroup Action
*/

#include"VisualizationSettings.h" 
#include<stdio.h>
VisualizationSettings::VisualizationSettings(){
	printf("VisualizationSettings created.\n");
	
	_populateColourList();
}

VisualizationSettings::~VisualizationSettings(){
	
}

unsigned int VisualizationSettings::containerSettings( int i ){
	if( m_containerSettings.size() <= i )
		setContainerSettings(i);
	printf( "\tRequested settings for container %d\n", i );
	printf( "\tReturning %d\n", m_containerSettings[i] );
	return m_containerSettings[i];
}

void VisualizationSettings::setContainerSettings( int i, unsigned int settings ){
	while( i >= m_containerSettings.size() ){
		m_containerSettings.push_back( (CVIS_COLOUR_NODE | CVIS_COLOUR_EDGE | CVIS_TABLE_VALUE) );
	}
	m_containerSettings[i] = settings;
	for( int j = 0; j < m_containerSettings.size(); j++ )
		printf( "Set visualization of container %d to %d\n", j, m_containerSettings[j] );
}

QString VisualizationSettings::containerColour( int i ){
	while( i >= m_containerColours.size() )
		m_containerColours.push_back(QString());
	printf("bump\n");
	if( m_containerColours[i].isEmpty() )
		m_containerColours[i] = _getNewAvailableColour();
	return m_containerColours[i];
}

QString VisualizationSettings::highlightColour(){
	if( !m_highlightColour.isEmpty() )
		return m_highlightColour;
	m_highlightColour = _getNewAvailableColour();
	return m_highlightColour;
}

QString VisualizationSettings::_getNewAvailableColour(){
	if( m_availableColours.size() > 0 ){
		QString ret = m_availableColours[0];
		m_availableColours.pop_front();
		return ret;
	}else{
		_populateColourList();
		return _getNewAvailableColour();
	}
}

void VisualizationSettings::_populateColourList(){
	m_availableColours.push_back( "red" );
	m_availableColours.push_back( "green" );
	m_availableColours.push_back( "blue" );
	m_availableColours.push_back( "yellow" );
	m_availableColours.push_back( "purple" );
	m_availableColours.push_back( "orange" );
	m_availableColours.push_back( "aquamarine" );
	m_availableColours.push_back( "crimson" );
	m_availableColours.push_back( "chocolate" );
	m_availableColours.push_back( "forestgreen" );
}
